<template>
	<view class="content">
		<web-view :src="dataInfo.url" @message="onMessage"></web-view>
		<!-- <view class="back" @click="onBack">
			<tui-icon name="home-fill" :size="34" color="#999"></tui-icon>
		</view>
		<view class="back" @click="qiandao" style="bottom: 46vh;right: 30rpx;z-index: 999999;">
			<image src="/web/static/qiandao_1.png" mode="" style="width: 100rpx;height: 100rpx;"></image>
		</view> -->
	</view>
</template>
<script>
	const app = getApp();
	import { toLogin } from '@/libs/login.js';
	import { getUserInfo } from '@/api/user.js';
	import {mapGetters} from 'vuex';
	import { getZhibo } from '@/api/api.js';
	export default {
		computed: {
			...mapGetters(['uid']),
		}, 
		data() {
			return {
				isPlaySource: false, //是否有播放源
				isVideoLive: false, //是否是直播
				isAutoplay: true, //是否自动播放
				videoMsg: '', //video消息
				currentUrl: '', //播放路径
				showControlbar: true,
				timer:null,
				url:'',
				image:'',
				id:'',
				course_name:'',
				dataInfo:'',
				page:1,
				dataList:[],
			}
		},
		
		onLoad(e) {
			// this.url = JSON.parse(decodeURIComponent(e.url))
			this.id = e.id
			let data = uni.getStorageSync('zhiboStatus')
			this.setShare()
			if(e.id!=data.id){
				this.getList()
			}else{
				this.dataInfo = uni.getStorageSync('zhiboStatus')
			}
			// if(this.tui.isLogin()){
			// 	this.tui.wxShare(1,this.id)
			// 	let data = {}
			// 	data.title = '清春美选'
			// 	data.desc = e.course_name
			// 	data.share_img = e.image
			// 	uni.setStorageSync('shareZhibo', data)
			// }
			// this.url =uni.getStorageSync('zhiboUrl')
		},
		// #ifdef MP
		onShareAppMessage() {
			return {
				title:'分享海报',
				path:'/pages/home/home?inviter_code='+uni.getStorageSync('inviter_code')+'&zhiboid='+that.dataInfo.id,
				imageUrl:this.image||'/static/logo.jpg'
			};
		},
		// #endif
		onShow() {
			let that = this
			// if(that.tui.isLogin()){
			// 	that.tui.TongjiLive(1, this.id)
			// }else{
			// 	let local = location.href;
			// 	uni.setStorageSync('d_url', local)
			// 	uni.redirectTo({
			// 		url: '/pages/login/login'
			// 	})
			// }
		},
		onHide() {
			// alert(2222)
			let that = this
			if(uni.getStorageSync('lookLive')==1){
				that.tui.TongjiLive(2, that.dataInfo.id)
			}
			
		},
		onBackPress() {
			// alert(3333)
			let that = this
			if(uni.getStorageSync('lookLive')==1){
				that.tui.TongjiLive(2, that.dataInfo.id)
			}
		},
		onUnload() {
			// alert(4444)
			let that = this
			if(uni.getStorageSync('lookLive')==1){
				that.tui.TongjiLive(2, that.dataInfo.id)
			}
		},
		methods: {
			onBack(){
				uni.switchTab({
					url:'/pages/home/home'
				})
				// uni.navigateTo({
				// 	url:'/pages/MyOrderList/MyOrderList'
				// })
			},
			qiandao(){
				console.log(1111)
				this.tui.href('/pages/SignIn/SignIn')
			},
			setShare: function() {
				let that = this
				getUserInfo().then(res => {
					that.$wechat.isWeixin() &&
						that.$wechat.wechatEvevt([
							"updateAppMessageShareData",
							"updateTimelineShareData",
							"onMenuShareAppMessage",
							"onMenuShareTimeline"
						], {
							desc: that.dataInfo.name,
							title: "清春美选",
							link: "http://dscshop.zzcyx1688.cn/pages/index/index?spid="+res.data.uid+"&zhiboid="+that.dataInfo.id,
							imgUrl: that.dataInfo.share_img
						}).then(res => {}).catch(err => {});
					
				});
				
			},
			getList(){
				let that = this
				getZhibo({
					
				}).then(res=>{
					console.log(res)
					res.data.map((item,index)=>{
						if(that.id==item.id){
							that.dataInfo=item
						}
					})
					
				}).catch(error=>{
					return that.$util.Tips({
						title: error,
					});
				})
			},
		}
	}
</script>
 
 
<style lang="scss" scoped>
	
</style>
